package com.example.server.controller;

import com.example.server.api.dto.UserDto;
import com.example.server.api.service.UserManager;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
    @DubboReference
    private UserManager userManager;

    @RequestMapping("/hello")
    public String hello(@RequestParam String name) {
        return userManager.hello(name);
    }

    @PostMapping("/addUser")
    public boolean addUser(UserDto userDto) {
        return userManager.insertUser(userDto) == 1;
    }

    @GetMapping("/get-user-by-id")
    public UserDto getUserById(@RequestParam("id") Integer id) {
        return userManager.getUserByID(id);
    }
}
